package net.techwatch.spring.roo.web;

privileged aspect EmployeeController_Roo_Controller {
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "employee", method = org.springframework.web.bind.annotation.RequestMethod.POST)    
    public java.lang.String EmployeeController.create(@org.springframework.web.bind.annotation.ModelAttribute("employee") net.techwatch.spring.roo.domain.Employee employee, org.springframework.validation.BindingResult result) {    
        if (employee == null) throw new IllegalArgumentException("A employee is required");        
        for(javax.validation.ConstraintViolation<net.techwatch.spring.roo.domain.Employee> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(employee)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "employee/create";            
        }        
        employee.persist();        
        return "redirect:/employee/" + employee.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "employee/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String EmployeeController.createForm(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("employee", new net.techwatch.spring.roo.domain.Employee());        
        return "employee/create";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "employee/{id}", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String EmployeeController.show(@org.springframework.web.bind.annotation.PathVariable("id") Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("employee", net.techwatch.spring.roo.domain.Employee.findEmployee(id));        
        return "employee/show";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "employee", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String EmployeeController.list(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("employees", net.techwatch.spring.roo.domain.Employee.findAllEmployees());        
        return "employee/list";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(method = org.springframework.web.bind.annotation.RequestMethod.PUT)    
    public java.lang.String EmployeeController.update(@org.springframework.web.bind.annotation.ModelAttribute("employee") net.techwatch.spring.roo.domain.Employee employee, org.springframework.validation.BindingResult result) {    
        if (employee == null) throw new IllegalArgumentException("A employee is required");        
        for(javax.validation.ConstraintViolation<net.techwatch.spring.roo.domain.Employee> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(employee)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "employee/update";            
        }        
        employee.merge();        
        return "redirect:/employee/" + employee.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "employee/{id}/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String EmployeeController.updateForm(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("employee", net.techwatch.spring.roo.domain.Employee.findEmployee(id));        
        return "employee/update";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "employee/{id}", method = org.springframework.web.bind.annotation.RequestMethod.DELETE)    
    public java.lang.String EmployeeController.delete(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        net.techwatch.spring.roo.domain.Employee.findEmployee(id).remove();        
        return "redirect:/employee";        
    }    
    
    @org.springframework.web.bind.annotation.InitBinder    
    public void EmployeeController.initBinder(org.springframework.web.bind.WebDataBinder binder) {    
        binder.registerCustomEditor(java.util.Date.class, new org.springframework.beans.propertyeditors.CustomDateEditor(new java.text.SimpleDateFormat("MM/dd/yyyy"), false));        
    }    
    
}
